Skip to content

MINOR: [Flight] Fix cookie header parsing in ServerSessionMiddleware - #1517

Merged
jbonofre merged 1 commit into
apache:mainfrom
Arawoof06:session-cookie-parsing
Nov 23, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
Arawoof06:session-cookie-parsing

Conversation

@Arawoof06

Copy link
Copy Markdown
Contributor

What's Changed

ServerSessionMiddleware.Factory.onCallStarted splits the cookie header on " ;" (space, then semicolon) and then on every =. Clients send cookie lists as name=value; name=value (RFC 6265, and what ClientCookieMiddleware and the C++ Flight client produce), so as soon as any other cookie is present, for example a load balancer affinity cookie, the whole header becomes one token with two or more =, the loop gives up, and arrow_flight_session_id is never found. The call is then served without a session and any options set through SetSessionOptions are silently gone. A session id that itself contains = (base64 padding) is truncated and rejected with NOT_FOUND.

The parser now splits on ;, splits each pair at the first =, trims, strips surrounding double quotes, and skips a malformed entry instead of abandoning the rest of the header, which is what the C++ ServerSessionMiddlewareFactory::ParseCookieString does. A header holding only arrow_flight_session_id=<id> behaves exactly as before.

TestServerSessionMiddleware covers the single-cookie, multi-cookie, quoted, =-containing, malformed, second-header, missing and unknown-id cases; four of them fail on main.

@jbonofre jbonofre added the bug-fix PRs that fix a big. label Nov 23, 2026
@apache apache deleted a comment from github-actions Bot Nov 23, 2026
@github-actions github-actions Bot added this to the 20.1.0 milestone Nov 23, 2026

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this!

The updated RFC 6265 cookie parsing in ServerSessionMiddleware.Factory.onCallStarted cleanly resolves the multi-cookie and = in value issues.

@jbonofre
jbonofre merged commit a99297c into apache:main Nov 23, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants